package ch09.d1;

import org.junit.Test;

import java.util.*;

public class TreeSetTest {

    //Tree 排序
    //回调方法
    @Test
    public void testIntTree(){
        //比较器：传入两个参数，返回一个int值
        //lambda表达式 箭头函数 promise 风格
        TreeSet<Integer> set=new TreeSet<>( (x,y)->y-x );
        set.add(3);
        set.add(2);
        set.add(1);
        set.add(5);
        set.add(4);

        System.out.println(set);



    }
    @Test
    public void testStudentTree(){
        TreeSet<Student> set=new TreeSet<Student>();

        Student s1=new Student("孙悟空",100,"123456","花果山");
        Student s2=new Student("猪八戒",200,"123456","高老庄");
        set.add(s1);
        set.add(s2);
        set.add(new Student("沙和尚",300,"123456","流沙河"));
        set.add(new Student("唐僧",400,"123456","长安"));
        set.add(new Student("白龙马",101,"123456","东海"));


        for (Student student : set) {
            System.out.println(student);
        }


    }



















    // 点名程序
    public static void main(String[] args) throws InterruptedException {
        //星期六上午
        String[] names="李赫,罗俊杰,赵英崭,郭敏聪,王雅婷,何建鑫,张静,王佳琪,吴俞晴,董路,马跃林,武雅娜,张莹,张克文,李文斌,魏飞飞,吴昊,刘昭,郭菁华,王欣,李金红,许铎,杨燕明,姬磊,李晨皓,吴霁雯,康硕磊,王芯玉,陈继朋,张帅浩,李少杰,赵晨阳,刘畅,郭亚川,柴源,张亮,李康帅,李靖,李佳鑫,张佳文".split(",");
        //星期六下午
        String[] names2="李赫,罗俊杰,赵英崭,孔子仪,郭敏聪,郑晓龙,王雅婷,何建鑫,郭培杰,张静,王佳琪,吴俞晴,董路,张秋怡,马跃林,武雅娜,张莹,张克文,李文斌,魏飞飞,吕亚富,郭菁华,王欣,李金红,许铎,杨燕明,姬磊,吴霁雯,康硕磊,王芯玉,陈继朋,张帅浩,李少杰,赵晨阳,刘畅,郭亚川,柴源,张亮,李康帅,李靖,李佳鑫,张佳文".split(",");
        //星期一上午
        String[] names3="李赫,罗俊杰,赵英崭,孔子仪,郭敏聪,郑晓龙,王雅婷,何建鑫,郭培杰,张静,王佳琪,吴俞晴,董路,张秋怡,马跃林,武雅娜,张莹,张克文,李文斌,魏飞飞,吴昊,刘昭,吕亚富,郭菁华,王欣,李金红,许铎,杨燕明,姬磊,李晨皓,吴霁雯,康硕磊,王芯玉,陈继朋,张帅浩,李少杰,赵晨阳,刘畅,郭亚川,柴源,张亮,李康帅,李靖,李佳鑫,张佳文".split(",");

        List<String> list=new ArrayList<>();
        Collections.addAll(list,names);
        Collections.addAll(list,names2);

        Random random=new Random();

        String name="";

        for (int i = 0; i < 100; i++) {
            name=list.get(random.nextInt(list.size()));
            System.out.println(name);
            Thread.sleep(100);
        }

        System.out.println("====================================");
        System.out.println(name);

        /*
            set list




         */

    }



}
